/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dao;

import java.sql.*;
import entities.Groups;

/**
 *
 * @author lion
 */
public class GroupsDao {

    private Connection conn = null;
    private PreparedStatement ps = null;
    private ResultSet rs = null;
    MysqlHelper mysql = new MysqlHelper();

    public int getGroupId(Groups group) throws Exception {
        int id = 0;
        conn = mysql.GetConnection();
        ps = conn.prepareStatement("SELECT *  FROM fl_groups WHERE groupname = ?");
        try {
            ps.setString(1, group.getGroupname());
            rs = ps.executeQuery();
            while (rs.next()) {
                id = rs.getInt("groupid");
            }
        } catch (Exception e) {
            throw e;
        }
        return id;
    }
}
